package com.leyou.search.controller;


import com.leyou.common.pojo.PageResult;
import com.leyou.item.pojo.Category;
import com.leyou.search.pojo.Goods;

import com.leyou.search.service.SearchService;
import com.leyou.search.utils.SearchRequest;
import com.leyou.search.utils.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SearchController {

   @Autowired
   private SearchService searchService;

    @PostMapping("page")
    public ResponseEntity<SearchResult> page(@RequestBody SearchRequest searchRequest) {
        SearchResult result = this.searchService.page(searchRequest);
        if ( result != null && result.getItems() != null && result.getItems().size() != 0){
            return ResponseEntity.ok(result);
        }
        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }


}
